package com.zhuozhengsoft.springbootpageoffice.controller;

import com.zhuozhengsoft.pageoffice.OpenModeType;
import com.zhuozhengsoft.pageoffice.PageOfficeCtrl;
import com.zhuozhengsoft.pageoffice.word.WordDocumentWriter;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping(value = "/InsertImgWaterMark2")
public class InsertImgWaterMark2Controller {
    @RequestMapping(value = "/Word")
    public ModelAndView showWord(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);

        WordDocumentWriter doc = new WordDocumentWriter();
        //添加水印 ，设置水印图片
        doc.getWaterMark().setImage("/doc/InsertImgWaterMark2/logo.jpg");
        poCtrl.setWriter(doc);
        //打开Word文档
        poCtrl.webOpen("/doc/InsertImgWaterMark2/test.docx", OpenModeType.docNormalEdit, "张三");
        request.setAttribute("pageoffice", poCtrl.getHtml());
        ModelAndView mv = new ModelAndView("InsertImgWaterMark2/Word");
        return mv;
    }


}
